package com.xqgl.servlet;

import java.io.IOException;
import java.sql.SQLException;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.xqgl.bean.Guarantee;
import com.xqgl.service.GuaranteeDaoImp;

/**
 * Servlet implementation class addGuaranteeServlet
 */
@WebServlet("/addGuaranteeServlet")
public class addGuaranteeServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public addGuaranteeServlet() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		request.setCharacterEncoding("utf-8");
		response.setContentType("text/html;Charset=utf-8");
		String villagename = request.getParameter("villagename");
		String repairper = request.getParameter("repairper");
		String equname = request.getParameter("equname");
		String repairdesc = request.getParameter("repairdesc");
		String guaranteectime = request.getParameter("guaranteectime");
		String guaranteestate = request.getParameter("guaranteestate");
		
		Guarantee guarantee = new Guarantee();
		guarantee.setVillagename(villagename);
		guarantee.setRepairper(repairper);
		guarantee.setEquname(equname);
		guarantee.setRepairdesc(repairdesc);
		guarantee.setGuaranteectime(guaranteectime);
		guarantee.setGuaranteestate(guaranteestate);
		
		GuaranteeDaoImp imp = new GuaranteeDaoImp();
		try {
			imp.add(guarantee);
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		response.sendRedirect("guaranteelist.jsp");
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		doGet(request, response);
	}

}
